from django.db import models
from django.contrib.auth.models import AbstractUser


# class Pinglun(models.Model):
#     content = models.CharField()
#     user = models.ForeignKey('user.User')  # 1. 直接写模型名  2. 使用模型路径(应用名.模型名)
#

class User(AbstractUser):
    phone = models.CharField('手机号', null=True, max_length=24)
    nick_name = models.CharField('昵称', null=True, max_length=24)
    img = models.ImageField('头像', upload_to='user', null=True)
    is_teacher = models.BooleanField('是否老师', default=False)
    desc = models.CharField('用户描述', max_length=256, null=True)
    course_num = models.IntegerField('发布课程数', default=0)
    vip = models.ForeignKey('user.Vip', on_delete=models.SET_NULL, null=True)
    vip_exp = models.DateField('会员过期时间', null=True)

    class Meta:
        db_table = 'tb_user'


class Vip(models.Model):
    level = models.IntegerField('vip等级')
    desc = models.CharField('描述', max_length=24)
    price = models.DecimalField('价格', max_digits=10, decimal_places=2)
    duration = models.IntegerField('时长(天)', default=365)

    class Meta:
        db_table = 'tb_vip'

    # id  level   desc
    # 1   0       免费
    # 2   1       会员
    # 3   2       超级会员
    # 4   3       限免会员